//-------------------------------------------------------------------
//	Copyright (c) 2012-2014 Zhirnov Andrey
//	This file is part of the "UXGEN-ES" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#pragma once

#include "UI/Widgets/Frame.h"

namespace Engine
{
namespace UI
{

	class UIFrameResource;
	SHARED_POINTER( UIFrameResource );



	//
	// UI Frame Resource
	//

	class UIFrameResource : public Resource
	{
	// types
	public:
		struct UIFrameLoadParams : ResLoadParams
		{
		// methods
		public:
			UIFrameLoadParams () : ResLoadParams( Signature() )
			{}

			static signature_t Signature ()
			{
				return CompileTime::TSignature8< 'U', 'I', 'F', 'R', 'A', 'M', 'E' >::value;
			}
		};


	// variables
	protected:
		FramePtr	_widget;


	// methods
	public:
		UIFrameResource (const EngineSubSystemsRef ess) : Resource(EResource::UI_FRAME, ess)
		{
			_widget = Frame::New( ess );
		}

		~UIFrameResource ()
		{}
	

		FramePtr	GetWidget ()	{ return _widget; }

		
		// Resource //
		virtual bool SwapData (const ResourcePtr &res) override
		{
			CHECK_ERR( Resource::SwapData( res ) );

			UIFrameResource *	frame = res.ToPtr< UIFrameResource >();

			_swap( this->_widget,	frame->_widget );
			return true;
		}


		virtual bool IsLoadedWithParams (const ResLoadParams &params) const override
		{
			return true;
		}
		

		virtual bool IsValid () const override
		{
			return _widget.IsNotNull();
		}


		static UIFrameResourcePtr New (const EngineSubSystemsRef ess)
		{
			return BaseObject::_New( new UIFrameResource( ess ) );
		}


		static UIFrameLoadParams GetDefaultLoadParams ()
		{
			return UIFrameLoadParams();
		}
	};


}	// UI
}	// Engine